# coding=utf-8

from functools import wraps
from blinker import Namespace


class Signal(object):

    signal = Namespace()

    def __init__(self, name):
        self.s = self.signal.signal(name)

    def send(self, *args, **kwargs):
        return self.s.send(*args, **kwargs)

    def connect(self, f):
        @wraps(f)
        def inner(*args, **kwargs):
            return f(*args, **kwargs)

        self.s.connect(inner)
        return inner


model_saved_signal = Signal('model-saved')
password_forgot_signal = Signal('password-forgot')
